package com.ldk.base.framework.datasource;

public abstract class BaseDataSourceFacotory {

	/**
	 * 
	 * @param driver
	 * @param serverName
	 * @param portNumber
	 * @param databaseName
	 * @return
	 */
	protected static String createDbUrl(DataSourceDriver driver, String serverName, long portNumber,String databaseName){
		String url = "";
		if(driver == DataSourceDriver.ORACLE){
			url = String.format("jdbc:oracle:thin:@%s:%d:%s", serverName,portNumber,databaseName);
		}
		else if(driver == DataSourceDriver.MSSQL){
			url = String.format("jdbc:sqlserver://%s:%d;DatabaseName=%s", serverName,portNumber,databaseName);
		}
		else if(driver == DataSourceDriver.MYSQL){
			url = String.format("jdbc:mysql://%s:%d/%s?characterEncoding=utf8", serverName,portNumber,databaseName);
		}
		else if(driver == DataSourceDriver.POSTRESQL){
			url = String.format("jdbc:postgresql://%s:%d/%s", serverName,portNumber,databaseName);
		}
		else if(driver == DataSourceDriver.DB2){
			url = String.format("jdbc:db2://%s:%d/%s", serverName,portNumber,databaseName);
		}
		
		return url;
	}
}
